﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Smart.Data
{
    /// <summary>
    /// 数据源实现基类
    /// </summary>
    public class DataSource : IDataSource
    {
        /// <summary>
        /// 默认指向SqlClient，其他方式需设置 Provider和FormatString
        /// </summary>
        public DataSource()
        {
            Provider = "System.Data.SqlClient";
        }

        /// <summary>
        /// 默认指向SqlClient，其他方式需设置 Provider和FormatString
        /// </summary>
        /// <param name="model">连结字符串</param>
        public DataSource(string connectionString)
            : this()
        {
            FormatString = connectionString;
        }

        public string FormatString { get; set; }

        /// <summary>
        /// 数据库类型
        /// </summary>
        public string Provider { get; set; }

        /// <summary>
        /// 服务器路径
        /// </summary>
        public string Server { get; set; }
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        public string Password { get; set; }

        /// <summary>
        /// 链接字符串
        /// </summary>
        /// <returns></returns>
        public virtual string ToConnectionString()
        {
            return FormatString;
        }

        public string Port { get; set; }

        public string Model { get; set; }
    }
}
